import { createRouter, createWebHashHistory } from "vue-router";
import { App } from "vue";

const router = createRouter({
  history: createWebHashHistory(import.meta.env.BASE_URL),
  routes: [
    {
      path: "/",
      name: "index",
      component: () => import("@/views/index/index.vue"),
    },
    {
      path: "/experience",
      name: "experience",
      component: () => import("@/views/experience/index.vue"),
      meta: {
        title: "经验经历",
      },
    },
    {
      name: "about",
      path: "/about",
      component: () => import("@/views/about/index.vue"),
      meta: {
        title: "关于我",
      },
    },
    {
      name: "contact",
      path: "/contact",
      component: () => import("@/views/contact/index.vue"),
      meta: {
        title: "联系我",
      },
    },
    {
      name: "speciality",
      path: "/speciality",
      component: () => import("@/views/speciality/index.vue"),
      meta: {
        title: "专业技能",
      },
    },
    {
      name: "project",
      path: "/project",
      component: () => import("@/views/project/index.vue"),
      meta: {
        title: "项目体验",
      },
    },
    {
      name: "message",
      path: "/message",
      component: () => import("@/views/message/index.vue"),
      meta: {
        title: "建议反馈",
      },
    },
    {
      path: "/:pathMatch(.*)",
      name: "error404",
      component: () => import("../views/404/index.vue"),
    },
    {
      path: "/success",
      name: "success",
      component: () => import("@/views/status/success.vue"),
      meta: {
        title: "操作成功",
      },
    },
  ],
});

/** setup vue router. - [安装vue路由] */
export async function setupRouter(app: App) {
  app.use(router);
  // createRouterGuard(router);
  await router.isReady();
}
